package nero.yncc.com.createart.activity;

import android.provider.SyncStateContract;
import android.text.TextUtils;
import android.widget.Button;
import android.widget.EditText;

import org.xutils.view.annotation.ContentView;
import org.xutils.view.annotation.ViewInject;

import java.util.HashMap;

import nero.yncc.com.createart.R;
import nero.yncc.com.createart.base.BaseActivity;
import nero.yncc.com.createart.base.Constants;
import nero.yncc.com.createart.utils.HttpUtils;
import nero.yncc.com.createart.utils.TextUtil;

/**
 * Created by nero on 2017/7/11.
 */

@ContentView(R.layout.activity_yijian)
public class ActivityYijian extends BaseActivity{
    @ViewInject(R.id.et_phone)
    EditText et_phone;
    @ViewInject(R.id.et_content)
    EditText et_content;
    @ViewInject(R.id.btn_submit)
    Button btn_submit;

    @Override
    protected void initView() {
        super.initView();
        setTitleBarTitle("意见反馈");
    }

    @Override
    protected void initListener() {
        super.initListener();
        btn_submit.setOnClickListener(this);
    }

    @Override
    protected void doClick(int id) {
        super.doClick(id);
        switch (id){
            case R.id.btn_submit:
                send();
                break;
        }
    }

    String phone="";
    String contents="";
    private void send(){
        phone=et_phone.getText().toString();
        contents=et_content.getText().toString();
        if(TextUtils.isEmpty(phone)){
            showToast("请填写联系方式");
            return;
        }
        if(TextUtils.isEmpty(contents)){
            showToast("请填写反馈内容");
            return;
        }

        HashMap<String,String> hashMap=new HashMap<>();
        hashMap.put("user_id",userBean.getUser_id());
        hashMap.put("mobile",phone);
        hashMap.put("note",contents);
        showProgress("正在提交反馈");
        new HttpUtils().post(this, Constants.API_YIJIAN, hashMap, null, HttpUtils.TYPE_NOTHING, new HttpUtils.HttpCallback() {
            @Override
            public void success(String msg, Object json) {
                showToast(msg);
                hideProgress();
                finish();
            }

            @Override
            public void fail(String failMsg) {
                showToast(failMsg);
                hideProgress();
            }
        });

    }
}
